<?
include("inc_security.php");

$type			= getValue("type", "str", "GET", "");
$record_id	= getValue("record_id");
$redirect	= getValue("redirect", "str", "GET", base64_encode("listing.php"));

$db_check = new db_query("SELECT " . $fs_fieldupload . " FROM " . $fs_table . " WHERE new_category_id IN (" . $fs_category . ") AND " . $id_field . " = " . $record_id . " AND lang_id = " . $lang_id);
if($check = mysql_fetch_assoc($db_check->result)){
	if($check[$fs_fieldupload] != "") delete_file($fs_filepath, $check[$fs_fieldupload]);
	if($type == ""){
		// Xóa trong bảng news_hits
		$db_delete	= new db_execute("DELETE FROM news_hits WHERE nh_id = " . $record_id);
		unset($db_delete);
		$query_str	= "DELETE FROM " . $fs_table . " WHERE " . $id_field . " = " . $record_id;
	}
	else $query_str = "UPDATE " . $fs_table . " SET " . $fs_fieldupload . " = NULL, new_picture_width = 0, new_picture_height = 0 WHERE " . $id_field . " = " . $record_id;
	$db_execute = new db_execute($query_str);
	unset($db_execute);
}
unset($db_check);
redirect(base64_decode($redirect));
?>